#include <iostream>
#include "actions.hpp"

struct s_action ft_actions[] =
{
  {FT_REQ_INVALID, &invalid_request},
  {FT_REQ_FILE_ADD, &add_file},
  {FT_REQ_REP_ADD, &add_directory},
  {FT_REQ_FILE_CTN, &set_file_ctn},
  {FT_REQ_FILE_REQ, &send_file_ctn},
  {FT_REQ_FILE_RM, &rm_file},
  {FT_REQ_CLEAN, &rm_directory}
};

int ft_nb_actions = sizeof(ft_actions) / sizeof(struct s_action);

void
invalid_request(struct s_ft_request *ack, void *data)
{
  if (DEBUG_MODE)
    std::cout << "This is an invalid request" << std::endl;

  (void)data;
  ack->type = FT_REQ_NACK;
  ack->data_sz = 0;
}

void
add_file(struct s_ft_request *ack, void *data)
{
  if (DEBUG_MODE)
    std::cout << "adding file: " << (char *)data << std::endl;

  ack->type = FT_REQ_ACK;
  ack->data_sz = 0;
}

void
add_directory(struct s_ft_request *ack, void *data)
{
  if (DEBUG_MODE)
    std::cout << "adding directory: " << (char *)data << std::endl;

  ack->type = FT_REQ_ACK;
  ack->data_sz = 0;
}

void
set_file_ctn(struct s_ft_request *ack, void *data)
{
  if (DEBUG_MODE)
    std::cout << "editing file: " << (char *)data << std::endl;

  ack->type = FT_REQ_ACK;
  ack->data_sz = 0;
}

void
send_file_ctn(struct s_ft_request *ack, void *data)
{
  if (DEBUG_MODE)
    std::cout << "sending file: " << (char *)data << std::endl;

  ack->type = FT_REQ_FILE_CTN;
  ack->data_sz = 0;
}

void
rm_file(struct s_ft_request *ack, void *data)
{
  if (DEBUG_MODE)
    std::cout << "removing file: " << (char *)data << std::endl;

  ack->type = FT_REQ_ACK;
  ack->data_sz = 0;
}

void
rm_directory(struct s_ft_request *ack, void *data)
{
  if (DEBUG_MODE)
    std::cout << "cleaning repository" << std::endl;

  (void)data;
  ack->type = FT_REQ_CLEAN;
  ack->data_sz = 0;
}
